package uitest 
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import flash.utils.setTimeout;
	import iscript.coreFramework.displays.drawing.LineSegment;
	import iscript.uiFramework.components.container.ViewPortBox;
	import iscript.uiFramework.components.menu.MenuStrip;
	import iscript.uiFramework.components.menu.ToolStripLabel;
	import iscript.uiFramework.components.menu.ToolStripMenuPanel;
	import iscript.uiFramework.components.panel.ScrollPanel;
	import iscript.uiFramework.components.UIComponent;
	import iscript.uiFramework.UIFramework;
	
	public class ViewPortViewTest extends Sprite
	{
		
		[Embed(source="../../bin/icon/wall.png")]
		private var wall:Class;
		
		[Embed(source="../../bin/icon/sitemap.png")]
		private var sitemap:Class
		
		//[Embed (source = "../../bin/icon/slide.png")]
		[Embed(source="../../bin/rss.png")]
		private var silde:Class
		
		[Embed(source="../../bin/map.jpg")]
		private var map:Class;
		
		public var menu:MenuStrip = new MenuStrip();
		public var scrollPanel:ScrollPanel;
		
		private var viewportbox:ViewPortBox = new ViewPortBox();
		public function ViewPortViewTest() 
		{
			initialize()
			
			    viewportbox.northItem = menu;
				viewportbox.westItem = scrollPanel;
			    viewportbox.render(this);
				
				draw();
				UIFramework.UiStage.addEventListener(Event.RESIZE, resizeLogic)
				setTimeout(function():void { 
					viewportbox.westWidth = 250;
					draw();
					}, 5000);
		}
		
		private function resizeLogic(e:Event):void 
		{
			var rect:Rectangle = new Rectangle (0, 0, UIFramework.UiStage.stageWidth, UIFramework.UiStage.stageHeight);
			viewportbox.update(rect);
			draw ()			
		}
		private function initialize():void {
			  scrollPanel = new ScrollPanel(); 
			  scrollPanel.source = new map();
			   
			   scrollPanel.HSilderPolicy = false;
			  
				var tsmp:ToolStripMenuPanel = new ToolStripMenuPanel();
				tsmp.addText("运行",null,Bitmap(new wall()).bitmapData);
		 
			   var toolstripLabe:ToolStripLabel = tsmp.addText("编译", null, Bitmap(new sitemap()).bitmapData);
			       toolstripLabe.ClickHandler = function(e:ToolStripLabel):void {
													trace(ToolStripLabel(e).text)
												}
				tsmp.addText("AS2");
				tsmp.addText ("AS3");
				tsmp.addText("Batch",null,Bitmap(new silde()).bitmapData);
				tsmp.addSeparator ()
				tsmp.addText("CSharp");
				tsmp.addText("CSS");
				tsmp.addText("Html");
				tsmp.addText("JavaScript");
				tsmp.addText("XML");
				tsmp.addText("Python");
			
			
			
			menu.addMenuItem("文件");
			menu.addMenuItem("编辑",tsmp);
			menu.addMenuItem("调试");
			menu.addMenuItem("帮助");
			menu.addMenuItem("File");
			menu.addMenuItem("Edit");
			menu.addMenuItem("Debug");
			menu.addMenuItem("Help");
			
			/*menu.x = 100;
			menu.y = 70;*/

			
			}
		private function draw():void {
		 return;
		this.graphics.clear()
		var  line:LineSegment = new LineSegment ();
		line.thickness = 1;
		line.drawRectangle (this.graphics, viewportbox.Layout.northRect)
		line.fillColor = Math.random()*0xFFFFFF;
		line.drawRectangle(this.graphics, viewportbox.Layout.westRect)
		line.fillColor = Math.random()*0xFFFFFF;
		line.drawRectangle(this.graphics, viewportbox.Layout.centerRect)
		line.fillColor = Math.random()*0xFFFFFF;
		line.drawRectangle(this.graphics, viewportbox.Layout.eastRect)
		line.fillColor = Math.random()*0xFFFFFF;
		line.drawRectangle (this.graphics, viewportbox.Layout.southRect)
		}
	}

}